﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace HengTong.DataAccess.Migrations
{
    /// <inheritdoc />
    public partial class 增加招聘发布申请表 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<Guid>(
                name: "RecruitPublishRequestBillId",
                table: "SysPerson",
                type: "uniqueidentifier",
                nullable: true);

            migrationBuilder.AddColumn<Guid>(
                name: "RecruitPublishRequestBillId",
                table: "SysHrRecruitPool",
                type: "uniqueidentifier",
                nullable: true);

            migrationBuilder.CreateTable(
                name: "SysHrRecruitPublishRequestBill",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Title = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
                    Description = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true),
                    HireNumber = table.Column<int>(type: "int", nullable: false),
                    ExpectedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
                    JobRequirement = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    EducationRequirement = table.Column<int>(type: "int", nullable: true),
                    MajorRequirement = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: true),
                    GenderRequirement = table.Column<int>(type: "int", nullable: true),
                    AgeRequirement = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: true),
                    OtherRequirement = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    SalaryRange = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
                    Benefits = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
                    JobPositionId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    PublishStartDate = table.Column<DateTime>(type: "datetime2", nullable: true),
                    PublishEndDate = table.Column<DateTime>(type: "datetime2", nullable: true),
                    IsExternalPublish = table.Column<bool>(type: "bit", nullable: false),
                    ContactPerson = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    ContactPhone = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    ContactEmail = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    UpdateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    Approver = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
                    ApprovalTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    GroupId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    OrgId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    BillCode = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
                    BillStatus = table.Column<int>(type: "int", nullable: true),
                    WorkflowStatus = table.Column<int>(type: "int", nullable: true),
                    Remark = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysHrRecruitPublishRequestBill", x => x.ID);
                    table.ForeignKey(
                        name: "FK_SysHrRecruitPublishRequestBill_FrameworkGroups_GroupId",
                        column: x => x.GroupId,
                        principalTable: "FrameworkGroups",
                        principalColumn: "ID");
                    table.ForeignKey(
                        name: "FK_SysHrRecruitPublishRequestBill_SysJobPosition_JobPositionId",
                        column: x => x.JobPositionId,
                        principalTable: "SysJobPosition",
                        principalColumn: "ID");
                    table.ForeignKey(
                        name: "FK_SysHrRecruitPublishRequestBill_SysOrg_OrgId",
                        column: x => x.OrgId,
                        principalTable: "SysOrg",
                        principalColumn: "ID");
                });

            migrationBuilder.CreateIndex(
                name: "IX_SysPerson_RecruitPublishRequestBillId",
                table: "SysPerson",
                column: "RecruitPublishRequestBillId");

            migrationBuilder.CreateIndex(
                name: "IX_SysHrRecruitPool_RecruitPublishRequestBillId",
                table: "SysHrRecruitPool",
                column: "RecruitPublishRequestBillId");

            migrationBuilder.CreateIndex(
                name: "IX_SysHrRecruitPublishRequestBill_GroupId",
                table: "SysHrRecruitPublishRequestBill",
                column: "GroupId");

            migrationBuilder.CreateIndex(
                name: "IX_SysHrRecruitPublishRequestBill_JobPositionId",
                table: "SysHrRecruitPublishRequestBill",
                column: "JobPositionId");

            migrationBuilder.CreateIndex(
                name: "IX_SysHrRecruitPublishRequestBill_OrgId",
                table: "SysHrRecruitPublishRequestBill",
                column: "OrgId");

            migrationBuilder.AddForeignKey(
                name: "FK_SysHrRecruitPool_SysHrRecruitPublishRequestBill_RecruitPublishRequestBillId",
                table: "SysHrRecruitPool",
                column: "RecruitPublishRequestBillId",
                principalTable: "SysHrRecruitPublishRequestBill",
                principalColumn: "ID");

            migrationBuilder.AddForeignKey(
                name: "FK_SysPerson_SysHrRecruitPublishRequestBill_RecruitPublishRequestBillId",
                table: "SysPerson",
                column: "RecruitPublishRequestBillId",
                principalTable: "SysHrRecruitPublishRequestBill",
                principalColumn: "ID");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_SysHrRecruitPool_SysHrRecruitPublishRequestBill_RecruitPublishRequestBillId",
                table: "SysHrRecruitPool");

            migrationBuilder.DropForeignKey(
                name: "FK_SysPerson_SysHrRecruitPublishRequestBill_RecruitPublishRequestBillId",
                table: "SysPerson");

            migrationBuilder.DropTable(
                name: "SysHrRecruitPublishRequestBill");

            migrationBuilder.DropIndex(
                name: "IX_SysPerson_RecruitPublishRequestBillId",
                table: "SysPerson");

            migrationBuilder.DropIndex(
                name: "IX_SysHrRecruitPool_RecruitPublishRequestBillId",
                table: "SysHrRecruitPool");

            migrationBuilder.DropColumn(
                name: "RecruitPublishRequestBillId",
                table: "SysPerson");

            migrationBuilder.DropColumn(
                name: "RecruitPublishRequestBillId",
                table: "SysHrRecruitPool");
        }
    }
}
